package com.mmloo.platform.model;

import com.mmloo.common.model.BaseModel;
import com.mmloo.common.util.TimeUtil;

/**
 * Created by jessy on 2015/10/21.
 */
public class ShoppingCart extends BaseModel{
    public ShoppingCart() {
        super();
        setNumber("spc" + TimeUtil.getCurrentTimeInString());
        setBirthTime(TimeUtil.getCurrentTimeInString());
    }
    private String number;
    private String owner;
    /***
     * 该购物车选择的商品
     * 以“，”号分隔
     */
    private String selected_goods;
    /**
     * state
     * 1-- 刚创建
     * 2-- 有商品未支付
     * 3-- 已支付 消除购物车
     * 4-- 未支付 已过期
     */

    private long birthTime;
    /**
     * 购物车的存活时间
     */
    private long survivalTime;

    /**
     * 返回-1 表示购物车过期
     * @return
     */
    public long getSurvivalTime() {
        survivalTime = TimeUtil.getCurrentTimeInString() - getBirthTime();
        if(survivalTime > 60000)
            return -1;
        return survivalTime;
    }

    public long getBirthTime() {
        return birthTime;
    }

    public void setBirthTime(long birthTime) {
        this.birthTime = birthTime;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getSelected_goods() {
        return selected_goods;
    }

    public void setSelected_goods(String selected_goods) {
        this.selected_goods = selected_goods;
    }
}
